﻿using System;

namespace Centido.Management.ConsoleManager
{
    /// <summary>
    ///   A console command that logs the current user out from the current domain.
    /// </summary>
    internal class LogoutCommand : Command
    {
        /// <summary>
        ///   Gets the console command name.
        /// </summary>
        public override string Name
        {
            get { return "logout"; }
        }


        /// <summary>
        ///   Gets the console command description.
        /// </summary>
        public override string Description
        {
            get { return Messages.LogoutCommandDescription; }
        }

        
        /// <summary>
        ///   Gets the console command full description.
        /// </summary>
        public override string FullDescription
        {
            get { return string.Empty; }
        }


        /// <summary>
        ///   Executes the console command.
        /// </summary>
        /// <param name="context">The console command execution context.</param>
        /// <exception cref="ArgumentNullException">Thrown when the value of <paramref name="context"/> is null.</exception>
        public override void Execute(CommandExecutionContext context)
        {
            base.Execute(context);

            context.CurrentDomain = null;

            // Changing the current command set
            context.ManagementConsole.CurrentCommandSet = new PreLoginCommandSet();

            // Displaying the success message
            Console.WriteLine(Messages.CommandCompletedMessage);
        }
    }
}
